package cn.tedu.spring.bean;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class TestUserDao {
    public static void main(String[] args) {
        // 创建IoC容器,并进行Spring Bean对象的创建和依赖注入(属性值注入)
        ApplicationContext context = new AnnotationConfigApplicationContext("cn.tedu.spring.bean");
        /*
            单独获取 userDao 的Spring Bean
            从IoC容器中获取指定类型的 Spring Bean
         */
        UserDao userDao = context.getBean(UserDao.class);
        System.out.println("userDao = " + userDao);

        /*
            获取 UserService 的Spring Bean对象
         */
        UserService userService = context.getBean(UserService.class);
        System.out.println("userSerive = " + userService);
    }
}






















